package com.itheima.clientAndService01;

import java.util.Scanner;

public class MainClass04 {
    public static void main(String[] args) {
        Student stu = new Student();
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入姓名：");
        String name = sc.nextLine();
        while (true){
            System.out.println("请输入年龄：");
            String age = sc.nextLine();
            try {
                int i = Integer.parseInt(age);
                stu.setAge(i);
                break;
            } catch (NumberFormatException e) {
                System.out.println("请输入一个整数！");
            }catch (AgeOutOfBoundsException e) {
                System.out.println(e.toString());
                System.out.println("请输入一个符合范围的年龄！");
            }
        }
        System.out.println(stu);
    }
}
